<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddIndexToRepaySummaries extends Migration
{
    protected $table = "repay_summaries";
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table($this->table, function (Blueprint $table) {
            $table->unique('loan_id','loan_id');
            $table->index('trans_id','trans_id');
            $table->index('loan_channel','loan_channel');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if(Schema::hasTable($this->table)){
            Schema::table($this->table, function (Blueprint $table) {
                $table->dropUnique('loan_id');
                $table->dropIndex('trans_id');
                $table->dropIndex('loan_channel');
            });
        }
    }
}
